package com.erp.app.catalog.itemMaster.vo;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;

import oracle.sql.BLOB;

import com.erp.framework.model.vo.SimpleBaseVo;
import com.erp.framework.model.vo.SimpleSearchMaintStyleVo;
import com.erp.framework.model.pk.SimpleBasePk;
import com.erp.framework.model.pk.SimpleSearchMaintStylePk;
import com.erp.framework.util.logger.Logger;

import com.erp.app.catalog.itemMaster.pk.ItemMasterPk;

public class ItemMasterVO extends SimpleSearchMaintStyleVo{
	private String companyCode;
	private String itemId;
    private String nodeId;
    private String acticleNumber;

    private String createCompanyCode;
    private String ownerCompanyCode;
    private String itemHdrImgId;
    private String itemDesc;
    private String waterMark;
	private String imagePath;
	private String imageName;
	
	private String catelogNodeId;

	private String browser;
	private ArrayList itemDtlVO = new ArrayList(); 
	private ArrayList itemPicVO = new ArrayList();
	
	private ArrayList itemPriceVO = new ArrayList();
	
	
	private byte[] attachment;
	private String content;
	
	private String createUser;
	private String updateUser;
	private Timestamp createDate;
	private Timestamp updateDate;
	
	public void setFabricCode(String fabricCode){
		this.itemId = fabricCode;
	}
	public String getFabricCode(){
		return this.itemId;
	}

	public byte[] getAttachment() {
		return attachment;
	}
	public void setAttachment(byte[] attachment) {
		this.attachment = attachment;
	}
	public void setAttachment(InputStream istream) {
		byte[] attachment = null;
		try {
			if (istream != null) {
	            ByteArrayOutputStream bout = new ByteArrayOutputStream();
	            int bytesRead = 0;
	            byte[] tmp = new byte[8096];
	            
				while ((bytesRead = istream.read(tmp)) != -1) {
				    bout.write(tmp, 0, bytesRead);
				}				
	            attachment = bout.toByteArray();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
        this.attachment = attachment;		
	}
	
	public void setAttachment(BLOB blob) {
		if(blob != null){
			try{
				ByteArrayOutputStream os = new ByteArrayOutputStream();
				InputStream is = blob.getBinaryStream();
				int bytesRead = 0;
				while((bytesRead = is.read()) != -1) {
					os.write(bytesRead);
				}
				this.attachment = os.toByteArray();
				is.close();
				os.close();				
			}catch(Exception e){
				Logger.logExceptions(this, e);
			}
		}
	}
	
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public Timestamp getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Timestamp createDate) {
		this.createDate = createDate;
	}
	public String getCreateUser() {
		return createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	public Timestamp getUpdateDate() {
		return updateDate;
	}
	public void setUpdateDate(Timestamp updateDate) {
		this.updateDate = updateDate;
	}
	public String getUpdateUser() {
		return updateUser;
	}
	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}
	public ArrayList getItemPriceVO() {
		return itemPriceVO;
	}
	public void setItemPriceVO(ArrayList itemPriceVO) {
		this.itemPriceVO = itemPriceVO;
	}
	public String getItemId(){
		return this.itemId;
	}
	public String getNodeId(){
		return this.nodeId;
	}
	public String getActicleNumber(){
		return this.acticleNumber;
	}
	public String getCreateCompanyCode(){
		return this.createCompanyCode;
	}
	public String getOwnerCompanyCode(){
		return this.ownerCompanyCode;
	}
	public String getItemHdrImgId(){
		return this.itemHdrImgId;
	}
	public String getItemDesc(){
		return this.itemDesc;
	}
	public String getWaterMark(){
		return this.waterMark;
	}
	public String getImagePath(){
		return this.imagePath;
	}
	public String getImageName(){
		return this.imageName;
	}
	public String getBrowser(){
		return this.browser;
	}

	public void setItemId(String itemId){
		this.itemId = itemId;
	}
	public void setNodeId(String nodeId){
		this.nodeId = nodeId;
	}
	public void setActicleNumber(String acticleNumber){
		this.acticleNumber = acticleNumber;
	}
	public void setCreateCompanyCode(String createCompanyCode){
		this.createCompanyCode = createCompanyCode;
	}
	public void setOwnerCompanyCode(String ownerCompanyCode){
		this.ownerCompanyCode = ownerCompanyCode;
	}
	public void setItemHdrImgId(String itemHdrImgId){
		this.itemHdrImgId = itemHdrImgId;
	}
	public void setItemDesc(String itemDesc){
		this.itemDesc = itemDesc;
	}
	public void setWaterMark(String waterMark){
		this.waterMark = waterMark;
	}
	public void setImagePath(String imagePath){
		this.imagePath = imagePath;
	}
	public void setImageName(String imageName){
		this.imageName = imageName;
	}
	public void setBrowser (String browser){
		this.browser = browser;		
	}
	public ArrayList getItemDtlVO() {
		return itemDtlVO;
	}
	public void setItemDtlVO(ArrayList itemDtlVO) {
		this.itemDtlVO = itemDtlVO;
	}
	public String getCompanyCode(){
		return this.companyCode;
	}
	public void setCompanyCode(String companyCode){
		this.companyCode = companyCode;
	}

	protected  void setChildTypesName() {
		this.childTypesName=new String[1];
		this.childTypesName[0] = "com.erp.app.catalog.itemMaster.vo.ItemMasterDtlVO";
		
	}
	protected void setTableSchemaName() {
		this.tableSchemaName="com.erp.app.catalog.itemMaster.schema.ItemMasterSchema";
	}

	protected  void setChildTableSchemaNames() {
	}

	protected void setDaoName() {
		this.daoName="com.erp.app.catalog.itemMaster.dao.ItemMasterGroupCommonDao";
	}
	protected void setBizLogicName() {
		this.bizLogicName = "com.erp.app.catalog.itemMaster.bizLogic.ItemMasterBizLogic";
	}
	public SimpleSearchMaintStylePk getSearchMaintStylePk() {
		return new ItemMasterPk(this.itemId);		
	}
	
	public String toString() {
		String pkStr = "PK: {itemId = " + this.itemId + "}\n";

		String colStr = "COL: {nodeId = " + this.nodeId
			+ "\n, acticleNumber = " + this.acticleNumber
			+ "\n, createCompanyCode = " + this.createCompanyCode
			+ "\n, ownerCompanyCode = " + this.ownerCompanyCode
			+ "\n, itemHdrImgId = " + this.itemHdrImgId
			+ "\n, itemDesc = " + this.itemDesc
			+ "\n, waterMark = " + this.waterMark
			+ "\n, imagePath = " + this.imagePath
			+ "\n, imageName = " + this.imageName
			+ "\n, browser = " + this.browser
			+ "\n, catelogNodeId = " + this.catelogNodeId
			+ "\n, content = " + this.content			
			+ "}\n";

		return "ItemMasterVO.toString() is:\n" + pkStr + colStr;
	}
	
	public String getCatelogNodeId() {
		return catelogNodeId;
	}
	
	public void setCatelogNodeId(String catelogNodeId) {
		this.catelogNodeId = catelogNodeId;
	}
	public ArrayList getItemPicVO() {
		return itemPicVO;
	}
	public void setItemPicVO(ArrayList itemPicVO) {
		this.itemPicVO = itemPicVO;
	}
}
